<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:p="http://primefaces.org/ui"
      xmlns:h="http://java.sun.com/jsf/html">
    <h:head>
        <title>Drzewo kategorii</title>
        <h:outputStylesheet name="custom-tree.css" library="css"/>
    </h:head>
    <h:body>
        <h:form id="form1">
        	<h:outputText value="Drzewo"/>
            <p:panel id="panel1" header="Custom PrimeFaces Tree">
            
             <p:commandButton id="testPrinc" actionListener="#{treeBean.checkPrincipal}" update="form1" value="Test princt">
                </p:commandButton>
             <p:commandButton id="del1" actionListener="#{treeBean.deleteSelectedNodes}" update="form1" value="Usuń zaznaczone">
                </p:commandButton>
            <p:commandButton id="move1" actionListener="#{treeBean.moveCatToParenAndDelete}" update="form1" value="Przenieś produkty">
                </p:commandButton>
              <h:outputText id="count" value="selected: #{treeBean.count}"> </h:outputText>
                <p:growl id="growl1" showSummary="true" showDetail="true" autoUpdate="true"/>

                 <p:tree id="tree1" value="#{treeBean.model}"
                        var="node" dynamic="true" cache="false"
                        selectionMode="checkbox" 
                        selection="#{treeBean.selectedNodes}"
                        >
                    <p:ajax event="select"  listener="#{treeBean.onNodeSelect}" update="tree1"/>
                    <p:ajax event="expand" listener="#{treeBean.onNodeExpand}" />
                    <p:ajax event="collapse" listener="#{treeBean.onNodeCollapse}" />
                    <p:treeNode type="node"
                                expandedIcon="folder-open"
                                collapsedIcon="folder-collapsed">
                        <h:outputText value="#{node}"/>
                    </p:treeNode>
                    <p:treeNode type="leaf" icon="document-node">
                        <h:outputText value="#{node}" />
                    </p:treeNode>
                </p:tree>
                <p:commandButton id="del2" actionListener="#{treeBean.deleteSelectedNodes}" update="form1" value="Usuń zaznaczone">
                </p:commandButton>
               <p:commandButton id="move2" actionListener="#{treeBean.moveCatToParenAndDelete}" update="form1" value="Przenieś produkty">
                </p:commandButton>
            </p:panel>
             
        </h:form>
    </h:body>
</html>